//package com.openvas.commons.common.utils;
//
//import com.alibaba.fastjson.JSONObject;
//import com.aliyuncs.CommonRequest;
//import com.aliyuncs.CommonResponse;
//import com.aliyuncs.DefaultAcsClient;
//import com.aliyuncs.IAcsClient;
//import com.aliyuncs.http.MethodType;
//import com.aliyuncs.profile.DefaultProfile;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
///**
// * 阿里云短信工具类
// */
//public class AliyunSmsUtils {
//    private static final Logger log = LoggerFactory.getLogger(AliyunSmsUtils.class);
//    private static final String ACCESS_KEY_ID = "LTAI5tRRcdnVncVi5Wfc9nic";
//    private static final String ACCESS_SECRET = "vLacSZeqxv1QZoHEcfIp4a7egX9nVI";
//    private static final String SIGN_NAME = "东福";
//    private static IAcsClient client;
//
//    private static IAcsClient getClient() {
//        if (client != null) {
//            return client;
//        } else {
//            DefaultProfile profile =
//                    DefaultProfile.getProfile("cn-hangzhou", ACCESS_KEY_ID, ACCESS_SECRET);
//            client = new DefaultAcsClient(profile);
//        }
//        return client;
//    }
//
//    /**
//     * 生成验证码>发送成功>保存redis K：注册+手机号  updateUpdate_13500135000  v:code
//     *
//     * 发送短信 <br>
//     * 参考文档：https://api.aliyun.com/?spm=a2c4g.11186623.2.15.450860e2NsGyiW#/?product=Dysmsapi&api=SendSms&params={}&tab=DEMO&lang=JAVA
//     * <br>
//     *
//     * @param tel 接收手机号 <br>
//     * @param code 发送内容：只发送阿里云模板配置的变量 <br>
//     * @param template 短信类型 {@link SmsTemplate}}<br>
//     * @return true : 发送成功，false : 发送失败
//     */
//    public static boolean sendVerifyCode(String tel, String code, String template) {
//        log.info("sendVerifyCode: 发送验证码 [tel:{}, code:{}, template:{}]", tel, code, template);
//        CommonRequest request = getCommonRequest("SendSms");
//        request.putQueryParameter("TemplateCode", template);
//        request.putQueryParameter("PhoneNumbers", tel);
//        request.putQueryParameter("TemplateParam", String.format("{\"code\":\"%s\"}", code));
//        try {
//            CommonResponse response = getClient().getCommonResponse(request);
//            String resp = response.getData();
//            JSONObject obj = JSONObject.parseObject(resp);
//            String message = obj.getString("Message");
//            if (message.equals("OK")) {
//                log.info("sendVerifyCode: 发送成功！");
//                return true;
//            } else {
//                log.info("sendVerifyCode: 发送失败！[{}]", resp);
//                return false;
//            }
//        } catch (Exception e) {
//            log.info("sendVerifyCode: 发送验证码异常");
//            e.printStackTrace();
//            return false;
//        }
//    }
//
//    private static CommonRequest getCommonRequest(String action) {
//        CommonRequest request = new CommonRequest();
//        request.setMethod(MethodType.POST);
//        request.setDomain("dysmsapi.aliyuncs.com");
//        request.setVersion("2017-05-25");
//        request.setAction(action);
//        request.putQueryParameter("RegionId", "cn-hangzhou");
//        request.putQueryParameter("SignName", SIGN_NAME);
//        return request;
//    }
//
//    public static class SmsTemplate {
//        /** 验证码 */
//        public static String REGISTER = "SMS_224345475";
//        /** 信息变更验证码 */
//        public static String INFO_CHANGE = "SMS_178535383";
//    }
//
////    public static void main(String[] args) {
////        sendVerifyCode("18718544830","885886",SmsTemplate.REGISTER);
////    }
//}
